<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
    .inner {
        height: 150px;
        background-color: lightblue;
    }
    </style>
</head>
<body>
    <div id="app">
         <!-- 使用.stop修饰符阻止事件冒泡 -->
        <!-- 
        <div class="inner" @click="divHandler">           
            <input type="button" value="干他" @click.stop="btnHeader"/>
        </div> 
        -->
        <!-- 阻止默认行为 -->
        <!-- <a href="http://www.baidu.com" @click.prevent="linkClick">百度</a> -->
        
        <!-- 实现捕获触发事件机制 -->
        <!--
        <div class="inner" @click.capture="divHandler">           
            <input type="button" value="干他" @click.stop="btnHeader"/>
        </div>
        -->

        <!-- 只有当前元素被点击的时候才会触发事件 -->
        <!--
        <div class="inner" @click.self="divHandler">           
            <input type="button" value="干他" @click="btnHeader"/>
        </div>
        -->

        <!-- 阻止默认行为，仅阻止一次 -->
        <!-- <a href="http://www.baidu.com" @click.prevent.once="linkClick">百度</a> -->
    </div>
    <script>
        var vm = new Vue({
            el:'#app',
            data:{

            },
            methods:{
                divHandler(){
                    console.log(1)
                },
                btnHeader(){
                    console.log(2)
                },
                linkClick(){
                    alert('弹出对话框')
                }
            }
        })
    </script>
</body>
</html>